import { defineStore } from 'pinia';

export const useUser = defineStore('useUser', {
	state: () => ({ 
    token: uni.getStorageSync('token'),
    userInfo: uni.getStorageSync('userInfo'),
    userDetail: uni.getStorageSync('userDetail'),
    imgUrl: uni.$uv.http.config.imageUrl,
  }),
	actions: {
		setToken(data){
      this.token = data;
    },
    setUserInfo(data){
      this.userInfo = data;
    },
    setUserDetail(data){
      this.userDetail = data;
    }
	}
});

export const useOrder = defineStore('useOrder', {
	state: () => ({ 
    cert: '', // 用户认证时，临时储存的信息
    group: {}, // 社群详情点击右上角时，临时储存的信息
    invest: {}, // 临时暂存约调研的信息
    reveal: '',
    ICloud: uniCloud.init({
      provider: 'aliyun',
      spaceId: 'mp-e14f2a12-063d-4d3f-b8a6-1e2449128a07',
      clientSecret: '34+K1bdftefxMG0gXiuM6Q=='
    })
  }),
	actions: {
		setCert(data){
      this.cert = data;
    },
    setGroup(data){
      this.group = data;
    },
    setInvest(data){
      this.invest = data;
    },
    setReveal(data){
      this.reveal = data;
    }
	}
});